#pragma once
#include "Types.h"
#include "Vector3.h"


namespace Boon
{
	/*!
	* Used to query information of a Physics::RayCast
	*/
	struct RaycastHit
	{
		RaycastHit() : GameObject( nullptr ) { }
		inline operator bool(){ return GameObject != nullptr; }

		Vector3			Point, Normal;
		float			Distance;
		GameObject*		GameObject;
	};

namespace Physics
{
	
	/*!
	* Interface describing boon physics functionality
	* Note: Use this interface to create different physics-engine implementations
	*/
	class BOON_API IPhysics
	{

	public:
		virtual bool				Init() = 0;
		virtual bool				Unload() = 0;

		virtual void				Update() = 0;
		virtual void				SyncGameObjects() = 0;

		virtual bool				AddCollider( Collider& collider ) = 0;
		virtual bool				UpdateCollider( Collider& collider ) = 0;
		virtual bool				AddRigidbody( Rigidbody& rigidbody ) = 0;


		virtual void				AddForce( const Rigidbody& rigidbody, const Vector3& force, ForceMode mode ) = 0;
		virtual void				AddForce( const Rigidbody& rigidbody, float x, float y, float z, ForceMode mode ) = 0;

		virtual MaterialPhysics		CreateMaterial( float frictionSt, float frictionDyn, float restitution ) = 0;
		virtual const Vector3		GetVelocity( const GameObjectID& id ) const = 0;
		virtual void				SetVelocity( const GameObjectID& id, const Vector3& velocity ) = 0;
		virtual void				Translate( const GameObjectID& id, const Vector3& direction ) = 0;

		virtual const Matrix44		GetTransform( const GameObjectID& id ) const = 0;
		virtual void				SetTransform( const Transform& t ) = 0;

		virtual void				RemoveGameObject( const GameObjectID& g ) = 0;
		virtual void				IgnoreCollision( const GameObjectID& a, const GameObjectID& b, bool enabled ) = 0;
		virtual void				OverlapSphere( const Vector3& position, float radius, ColliderResult& outResult ) = 0;
		virtual bool				RayCast( const Vector3& origin, const Vector3 direction, RaycastHit& outHit, float distance, bool staticOnly ) = 0;
		virtual ~IPhysics(){}

	};

}
}
